// import Cookies from 'js-cookie'

var sidebarKey = 'sidebarStatus'
var GetsidebarStatus = () => {
  return localStorage.getItem(sidebarKey)
}
var SetsidebarStatus = (status) => {
  return localStorage.setItem(sidebarKey,status)
}
var app = {
  namespaced: true, 
  state: {
    sidebar: {
      opened: GetsidebarStatus() ? !!+GetsidebarStatus() : true,
      withoutAnimation: false
    },
    device: 'desktop'
  },
  mutations: {
    toggleSidebar: state => {
      state.sidebar.opened = !state.sidebar.opened
      state.sidebar.withoutAnimation = false
      if (state.sidebar.opened) {
        // Cookies.set('sidebarStatus', 1)
      } else {
        // Cookies.set('sidebarStatus', 0)
      }
    },
    closeSidebar: (state, withoutAnimation) => {
      // Cookies.set('sidebarStatus', 0)
      SetsidebarStatus(0)
      state.sidebar.opened = false
      state.sidebar.withoutAnimation = withoutAnimation
    },
    toggleDevice: (state, device) => {
      state.device = device
    }
    },
  actions: {
    toggleSideBar({ commit }) {
      commit('toggleSidebar')
      },
      closeSideBar({ commit }, { withoutAnimation }) {
      commit('closeSidebar', withoutAnimation)
      },
    toggleDevice({ commit }, device) {
      commit('toggleDevice', device)
    }
  }
}
export default app
